package com.hcc.cpwxdemo.handler;

import com.alibaba.fastjson.JSONObject;
import com.hcc.cpwxdemo.builder.TextBuilder;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpXmlMessage;
import me.chanjar.weixin.cp.bean.WxCpXmlOutMessage;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author hcc
 * @date
 * @desc 通讯录变更事件处理器.
 */
@Component
public class ContactChangeHandler extends AbstractHandler {


    @Override
    public WxCpXmlOutMessage handle(WxCpXmlMessage wxMessage, Map<String, Object> context, WxCpService cpService,
                                    WxSessionManager sessionManager) {
        String content = "收到通讯录变更事件，内容：" + JSONObject.toJSONString(wxMessage);
        this.logger.info("get cpWx contact change event push. ");

        return new TextBuilder().build(content, wxMessage, cpService);
    }


}
